package cn.tedu.imop.api.advice;

import cn.tedu.imop.api.model.RestResult;
import cn.tedu.imop.api.model.RestResultUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(RuntimeException.class)
    public RestResult<Void> handleRuntimeException(RuntimeException e){
       log.error(e.getMessage(),e);
       return RestResultUtils.failedWithMsg(500,e.getMessage());
    }
}
